/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.lotus.tep.ui;

import com.lotus.tep.constant.VoiceUiConstant;
import java.awt.Component;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;

/**
 *
 * @author arvind.sharma
 */
public class VoiceUi {

	private final JToolBar jToolBar_;
	private final JButton playJButton_;
	private final JButton pauseJButton_;
	private final JButton resumeJButton_;
	private final JButton stopJButton_;

	private VoiceUi() {
		jToolBar_ = new JToolBar(VoiceUiConstant.TITLE_NAME, VoiceUiConstant.ORIENTATION_HORIZONTAL);
		playJButton_ = new JButton(getPlayIcon());
		pauseJButton_ = new JButton(getPauseIcon());
		resumeJButton_ = new JButton(getResumeIcon());
		stopJButton_ = new JButton(getStopIcon());
	}

	public static VoiceUi createVoiceUi() {
		VoiceUi voiceUi = new VoiceUi();
		voiceUi.addButtons();
		return voiceUi;
	}

	private void disable(JButton jb) {
		jb.setEnabled(false);
	}

	private void enable(JButton jb) {
		jb.setEnabled(true);
	}

	public void enablePlay() {
		enable(playJButton_);
	}

	public void enablePause() {
		enable(pauseJButton_);
	}

	public void enableResume() {
		enable(resumeJButton_);
	}

	public void enableStop() {
		enable(stopJButton_);
	}

	public void disablePlay() {
		disable(playJButton_);
	}

	public void disablePause() {
		disable(pauseJButton_);
	}

	public void disableResume() {
		disable(resumeJButton_);
	}

	public void disableStop() {
		disable(stopJButton_);
	}
	
	public void setEnabledPlay(boolean enbl){
		playJButton_.setEnabled(enbl);
	}
	
	public void setEnabledPause(boolean enbl){
		pauseJButton_.setEnabled(enbl);
	}
	
	public void setEnabledResume(boolean enbl){
		resumeJButton_.setEnabled(enbl);
	}
	
	public void setEnabledStop(boolean enbl){
		stopJButton_.setEnabled(enbl);
	}

	private void addButtons() {
		jToolBar_.add(playJButton_);
		jToolBar_.add(pauseJButton_);
		jToolBar_.add(resumeJButton_);
		jToolBar_.add(stopJButton_);
	}

	public Component getComponent() {
		return jToolBar_;
	}

	private Icon getPlayIcon() {
		return getIcon(VoiceUiConstant.PLAY_BUTTON_IMG_PATH);
	}

	private Icon getPauseIcon() {
		return getIcon(VoiceUiConstant.PAUSE_BUTTON_IMG_PATH);
	}

	private Icon getResumeIcon() {
		return getIcon(VoiceUiConstant.RESUME_BUTTON_IMG_PATH);
	}

	private Icon getStopIcon() {
		return getIcon(VoiceUiConstant.STOP_BUTTON_IMG_PATH);
	}

	private Icon getIcon(String IMG_PATH) {
		return new ImageIcon(VoiceUi.class.getResource(IMG_PATH));
	}
}
